<%@ page isErrorPage="true"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Tulkas Robot - Error</title>
<link href="<%= request.getAttribute("javax.servlet.forward.context_path")%>/css/default.css" rel="stylesheet" type="text/css" />
<style>
#error_frame {
	width: 600px;
	margin-left: auto;
	margin-right: auto;
	margin-top: 100px;
}

#error_text {
	margin-left: auto;
	margin-right: auto;
	color: red;
	font-size: 30px;
}

#error_title {
	color: black;
	margin-top: 12px;
	font-size: 20px;
}

#error_message {
	margin-top: 12px;
	font-size: 14px;
}

#error_stackTrace {
	white-space: nowrap;
	display: none;
	clear: both;
    font-size:12px;
}

#error_detail {
	float: right;
	font-weight: bold;
	color: #d18f00;
	font-size: 12px;
    margin-top:10px;
}

#error_back {
	margin-top: 10px;
}

#link_back {
	color: blue;
	font-weight: bold;
	font-size: 14px;
	text-decoration: none;
}
</style>
<script>
	function onDetail() {
		var ele = document.getElementById("error_stackTrace");
        var eleCtrl = document.getElementById("error_detail");
		if (ele.style.display == "none" || ele.style.display == "") {
			ele.style.display = "block";
            eleCtrl.className = "arrow_up";
		} else {
			ele.style.display = "none";
			eleCtrl.className = "arrow_down";
		}
	}
</script>
</head>
<body>
<div class="head_top">&nbsp;</div>
<div class="head_menu">&nbsp;</div>
<div id="error_frame">
  <div id="error_text">ERROR</div>
  <%
  Object statusCodeObj = request.getAttribute("javax.servlet.error.status_code");
  if(statusCodeObj != null && !"".equals(statusCodeObj)) {
    String statusCode = statusCodeObj.toString();
  %>
    <div id="error_title">
      <%
        out.print(statusCode+ "&nbsp;");
        if("400".equals(statusCode)) 
          out.print("(Bad Request)");
        else if("401".equals(statusCode)) 
            out.print("(Unauthorized)");
        else if("404".equals(statusCode)) 
            out.print("(Not Found)");
        else if("405".equals(statusCode)) 
            out.print("(Method Not Allowed)");
        else if("406".equals(statusCode)) 
            out.print("(Not Acceptable)");
        else if("415".equals(statusCode)) 
            out.print("(Unsupported Media Type)");
        else if("500".equals(statusCode)) 
            out.print("(Internal Server Error)");
      %>
    </div>
  <%
  }
  %>
  <div id="error_message"><%= request.getAttribute("javax.servlet.error.message")%></div>
  <%
  Boolean hideDetail = (Boolean)request.getSession(true).getAttribute("error_hideDetail");
  if ((hideDetail == null || !hideDetail) &&exception != null){
    java.io.StringWriter sw = new java.io.StringWriter();
    exception.printStackTrace(new java.io.PrintWriter(sw));
    String st = sw.toString();
    sw.close();
    st = st.replaceAll("\n","<br/>\n");
    %>
    <div id="error_detail" class="arrow_down" onclick="onDetail()">Detail</div>
    <div id="error_stackTrace"><%=st%></div>
    <%
  }
  %>
  <%
  if(request.getAttribute("error_referer") != null) {
  %>
    <div id="error_back"><a id="link_back" href="<%=request.getAttribute("error_referer")%>">Back</a></div>
  <%} %>
</div>
</body>
</html>